import { createStore } from "redux";

const initData = {
    name:'小明 ',
    age:22,
    sex:'男'
}

const reducer = (state = initData,action) => {
    console.log('执行',state,action)
    if(action.type === 'Type_name') {
        // state:最新的数据
        // action:对象  type为必须有的
        return {
            ...state,
            name:Math.random() + '小红'
        }
    }else if (action.type === 'Type_age') {
        return {
            ...state,
            age:state.age + 1
        }
    }


    return state
}

// 创建 store 对象
const store = createStore (reducer)


export default store